import * as React from 'react';
// 引入编辑器组件
import BraftEditor from 'braft-editor'
// 引入编辑器样式
import 'braft-editor/dist/index.css'

interface IRichProps {
}

const Rich: React.FunctionComponent<IRichProps> = (props) => {
  const [ editorState, setEditorState ] = React.useState('')
  const [ text, setText ] = React.useState('')
  const handleEditorChange = (editorState) => {
    console.log('change', editorState )
    setEditorState(editorState)
  }
  const submitContent = () => {
    const html = editorState.toHTML()
    setText(html)
    console.log(html)
  }
  return (
    <div>
      <BraftEditor
        value={editorState}
        onChange={handleEditorChange}
        onSave={submitContent}
      />
      asdasdasdsads
      <div dangerouslySetInnerHTML = {{ __html: text}} style={{ height: 600}}>
      </div>
    </div>
  );
};

export default Rich;
